//
//  HRZMyOrderEmptyView.m
//  EMarket
//
//  Created by 石头 on 2018/5/23.
//  Copyright © 2018 好日子. All rights reserved.
//

#import "HRZMyOrderEmptyView.h"

@interface HRZMyOrderEmptyView()

@property (nonatomic, strong) UIImageView *mImageView;
@property (nonatomic, strong) UILabel *mDescribe;
@property (nonatomic, strong) UIButton *goBuyBtn;

@end

@implementation HRZMyOrderEmptyView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.mImageView];
        [self addSubview:self.mDescribe];
        [self addSubview:self.goBuyBtn];
    }
    return self;
}

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}

- (void)layoutSubviews {
    [self.mImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.centerY.mas_equalTo(self).multipliedBy(0.7);
        make.width.mas_equalTo(self).multipliedBy(0.3);
        make.height.mas_equalTo(self.mImageView.mas_width).multipliedBy(1.0);
    }];
    
    [self.mDescribe mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.mImageView.mas_bottom).mas_offset(10);
    }];
    
    [self.goBuyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.mDescribe.mas_bottom).mas_offset(10);
    }];
}

#pragma mark - ----  eventResponce  ----

- (void)onGoToBuyBtnClick:(id)sender {
    !_goToBuyBlock ? : _goToBuyBlock();
}

#pragma mark - ----  Getter/Setter  ----
- (UIImageView *)mImageView{
    if (!_mImageView) {
        _mImageView = [[UIImageView alloc] init];
        _mImageView.contentMode = UIViewContentModeScaleAspectFit;
        _mImageView.image = PLACEHOLDERIMAGE;
    }
    return _mImageView;
}

- (UILabel *)mDescribe{
    if (!_mDescribe) {
        _mDescribe = [[UILabel alloc] init];
        _mDescribe.font = PFR13Font;
        _mDescribe.textColor = [UIColor darkGrayColor];
        _mDescribe.textAlignment = NSTextAlignmentCenter;
        _mDescribe.text = @"您没有相关订单";
    }
    return _mDescribe;
}

- (UIButton *)goBuyBtn{
    if (!_goBuyBtn) {
        _goBuyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    
        [_goBuyBtn setContentEdgeInsets:UIEdgeInsetsMake(5, 10, 5, 10)];
        _goBuyBtn.layer.masksToBounds = YES;
        _goBuyBtn.layer.cornerRadius = 4.f;
        _goBuyBtn.layer.borderWidth = 1.f;
        _goBuyBtn.layer.borderColor = HRZThemeColor.CGColor;
        [_goBuyBtn setTitle:@"逛商场" forState:UIControlStateNormal];
        [_goBuyBtn setTitleColor:HRZThemeColor forState:UIControlStateNormal];
        [_goBuyBtn addTarget:self action:@selector(onGoToBuyBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _goBuyBtn;
}

@end
